<template>
	<view :class="productConClass">
		<view v-if="agreement">
			<view class="labelNav acea-row row-around row-middle">
				<view class="item">
					<!-- <text class="iconfont icon-xuanzhong"></text>新媒体课程技术服务 -->
				</view>
				<!-- <view class="item">
					<text class="iconfont icon-xuanzhong"></text>所有商品精挑细选
				</view> -->
				<view class="item">
					<text class="iconfont icon-guanbi2"></text>不支持退款
				</view>
			</view>
			<!-- 轮播图 -->
			<product-con-swiper :img-urls="storeInfo.sliderImageArr"></product-con-swiper>

			<!-- 商品信息描述 -->
			<view class="wrapper">
				<view class="share acea-row row-between row-bottom">
					<view class="money font-color-red">
						<text>￥</text>
						<text class="num">{{ storeInfo.price || 0 }}</text>
						<text class="vip-money">￥{{ storeInfo.otPrice || 0 }}</text>
						<!-- <image src="https://h5.ylsp.vip/file/static/images/vip.png" class="image"
							v-if="storeInfo.vipPrice && storeInfo.vipPrice > 0" /> -->
					</view>
					<view class="iconfont icon-fenxiang" @click="listenerActionSheet">
						<text class="shareButton">分享</text>
					</view>
				</view>
				<!-- <view class="introduce">{{ storeInfo.storeName }}</view> -->
				
				<view class="discount_view" v-if="is_buy == 'N' && storeInfo.isMaterials == 1">
					<!-- <view class="icon">
						<image src="https://h5.ylsp.vip/file/static/index-07.png" mode=""></image>
					</view>
					<view class="content_box" v-if="userInfo.level == 0">
						升级为{{ nextLevelName }}可享受免费领取3年面膜
					</view>
					<view class="content_box" v-if="userInfo.level == 1 && storeInfo.isThroughTrain <= 1">
						下单即可成为聚溪传媒会员
					</view>
					<view class="content_box" v-if="userInfo.level == 1 && storeInfo.isThroughTrain > 1">
						您当前等级为{{ userInfo.level == 2 ? '店主' :userInfo.level == 3 ? '新媒体运营师' :userInfo.level == 4 ? '联营公司' :userInfo.level == 5 ? '联营公司1' : 'VIP会员' }}可享受免费领取三年面膜
					</view>
					
					<view class="content_box" v-if="userInfo.level > 1">
						 您当前等级为{{ userInfo.level == 2 ? '店主' :userInfo.level == 3 ? '新媒体运营师' :userInfo.level == 4 ? '联营公司' :userInfo.level == 5 ? '联营公司1' : '普通用户' }}可省:￥{{ commissionSum }} 
					下单即可成为聚溪传媒会员
					</view> -->
				</view>
				
				<view class="label acea-row row-between-wrapper">
					<text>原价:￥{{ storeInfo.otPrice || 0 }}</text>
					<text>库存:{{ storeInfo.stock || 0 }}</text>
					<!-- <text>销量:{{ storeInfo.sales || 0 }}</text> -->
				</view>
				<view class="coupon acea-row row-between-wrapper" @click="couponTap" v-if="couponList.length">
					<text class="hide line1 acea-row">
						<text>优惠券：</text>
						<text class="activity" v-for="(item, couponListEq) in couponList"
							:key="couponListEq">满{{ item.useMinPrice }}减{{ item.couponPrice }}</text>
					</text>
					<view class="iconfont icon-jiantou"></view>
				</view>
			</view>

			<!-- 运费 -->
			<div class="attribute acea-row row-between-wrapper">
				<div>
					运费：
					<span class="atterTxt">{{ tempName }}</span>
				</div>
			</div>

			<!-- 规格 -->
			<view class="attribute acea-row row-between-wrapper" @click="selecAttrTap" v-if="storeInfo.isBuy == 0">
				<view>
					<text>{{ attrTxt }}：</text>
					<text class="atterTxt">{{ cart_num }}件</text>
				</view>
				<view class="iconfont icon-jiantou"></view>
			</view>


			<!-- 商品详情 -->
			<view class="product-intro">
				<view class="title">产品介绍</view>
				<view class="conter" v-html="storeInfo.description"></view>
			</view>

			<view style="height:100rpx;"></view>
			<!-- 操作栏 -->

			<!-- #ifdef MP-WEIXIN -->
			<view class="footer">
				<view class="item" @click="goHome">
					<view class="iconfont">
						<image src="https://h5.ylsp.vip/file/static/home.png" mode="widthFix"></image>
					</view>
					<text>首页</text>
				</view>
				<!-- <view class="item" @click="setCollect" v-if="storeInfo.userCollect">
					<view class="iconfont">
						<image src="https://h5.ylsp.vip/file/static/icon-collection-hot.png" mode="widthFix"></image>
					</view>
					<text>收藏</text>
				</view> -->
				<!-- <view class="item" @click="setCollect" v-if="!storeInfo.userCollect">
					<view class="iconfont">
						<image src="https://h5.ylsp.vip/file/static/icon-collection.png" mode="widthFix"></image>
					</view>
					<text>收藏</text>
				</view> -->
				<!-- <view @click="goShoppingCart()" v-if="animated" class="item animated bounceIn">
					<view class="iconfont">
						<image src="https://h5.ylsp.vip/file/static/cart.png" mode="widthFix"></image>
						<text class="num bg-color-red" v-if="CartCount > 0">{{CartCount}}</text>
					</view>
					<text>购物车</text>
				</view> -->
				<!-- <view @click="goShoppingCart()" class="item animated" v-if="!animated">
					<view class="iconfont">
						<image src="https://h5.ylsp.vip/file/static/cart.png" mode="widthFix"></image>
						<text class="num bg-color-red" v-if="CartCount > 0">{{CartCount}}</text>
					</view>
					<text>购物车</text>
				</view> -->

				<!-- <view class="item joinCart" @click="joinCart" v-if="storeInfo.isBuy == 0">
					<text>加入购物车</text>
				</view> -->
				<view class="item buy" @click="tapBuy" v-if="storeInfo.isBuy == 0">
					<text>立即购买</text>
				</view>
				
				<view class="item buy customer-service" v-if="storeInfo.isBuy == 1">
					<button open-type="contact">
						联系客服
					</button>
				</view>
			</view>
			<!-- #endif -->




			<!-- #ifdef H5 -->
			<view class="footer">
				<view class="item" @click="goHome">
					<view class="iconfont">
						<image src="https://h5.ylsp.vip/file/static/home.png" mode="widthFix"></image>
					</view>
					<text>首页</text>
				</view>
				<view class="item" @click="setCollect" v-if="storeInfo.userCollect">
					<view class="iconfont">
						<image src="https://h5.ylsp.vip/file/static/icon-collection-hot.png" mode="widthFix"></image>
					</view>
					<text>收藏</text>
				</view>
				<view class="item" @click="setCollect" v-if="!storeInfo.userCollect">
					<view class="iconfont">
						<image src="https://h5.ylsp.vip/file/static/icon-collection.png" mode="widthFix"></image>
					</view>
					<text>收藏</text>
				</view>
				<view class="item buy" :class="storeInfo.isBuy == 1? '' : 'buy-border'" @click="tapBuy" v-if="storeInfo.isBuy == 0">
					<text>立即购买</text>
				</view>
				<view class="item buy" v-if="storeInfo.isBuy == 1">
					<text>联系客服</text>
				</view>
			</view>
			<!-- #endif -->

			<!-- 优惠券 -->
			<CouponPop v-on:changeFun="changeFun" :coupon="coupon"></CouponPop>
			<!-- 商品规格弹窗 -->
			<ProductWindow v-on:changeFun="changeFun" :attr="attr" :cartNum="cart_num"></ProductWindow>
			<!-- 分享海报 -->
			<StorePoster v-on:setPosterImageStatus="setPosterImageStatus" :posterImageStatus="posterImageStatus"
				:posterData="posterData" :goodId="id"></StorePoster>

			<view class="generate-posters acea-row row-middle on" v-if="posters">
				<view class="item" @click="setPosterImageStatus">
					<view class="iconfont icon-haibao"></view>
					<view>生成海报</view>
				</view>
			</view>
			<view class="generate-posters acea-row row-middle" v-if="!posters">
				<view class="item" @click="setPosterImageStatus">
					<view class="iconfont icon-haibao"></view>
					<view>生成海报</view>
				</view>
			</view>
			<view class="mask" @touchmove.prevent @click="listenerActionClose" v-show="posters"></view>
			<view class="posterCanvasWarp">
				<canvas class="posterCanvas" canvas-id="myCanvas"></canvas>
			</view>
		</view>
		
		
		
		
		<view v-else class="post-about">
			<view class="content">
				<image v-for="(item, imgUrlsIndex) in agreementArr" :key="imgUrlsIndex" :src="item" mode="widthFix" lazy-load @tap="previewImage(imgUrlsIndex)"></image>
			</view>
			
			<view class="btn" @click="agreeAndContinue">
				同意并继续
			</view>
		</view>
	</view>
</template>

<script>
	import ProductConSwiper from "@/components/ProductConSwiper";
	import UserEvaluation from "@/components/UserEvaluation";
	import CouponPop from "@/components/CouponPop";
	import ProductWindow from "@/components/ProductWindow";
	import StorePoster from "@/components/StorePoster";
	import {
		getProductDetail,
		postCartAdd,
		getCartCount,
		getProductCode,
	} from "@/api/store";
	import {
		getCoupon,
		getCollectAdd,
		getCollectDel,
		getUserInfo,
	} from "@/api/user";
	import cookie from "@/utils/store/cookie";
	import {
		isWeixin,
		PosterCanvas,
		parseQueryItem,
		handleUrlParam,
		getCurrentPageUrlWithArgs,
		systemPrompt
	} from "@/utils";
	import {
		wechatEvevt
	} from "@/libs/wechat";
	import {
		imageBase64,
		getDealPic
	} from "@/api/public";
	import {
		mapGetters
	} from "vuex";
	export default {
		name: "GoodsCon",
		components: {
			ProductConSwiper,
			UserEvaluation,
			CouponPop,
			ProductWindow,
			StorePoster
		},
		data: function() {
			return {
				shareInfoStatus: false,
				weixinStatus: false,
				mapShow: false,
				mapKey: "",
				agreement: false,
				posterData: {
					image: "",
					title: "",
					price: "",
					code: "",
				},
				posterImageStatus: false,
				animated: false,
				coupon: {
					coupon: false,
					list: [],
				},
				attr: {
					cartAttr: false,
					productAttr: [],
					productSelect: {},
				},
				isOpen: false, //是否打开属性组件
				productValue: [],
				derivableCount: 0, //VIP免费领取数量
				id: 0,
				storeInfo: {},
				couponList: [],
				attrTxt: "已选数量",
				attrValue: "",
				cart_num: 1, //购买数量
				replyCount: "",
				is_buy: '',
				isFree: 0,
				cateId: 0,
				frequency: 0,
				limitThrough: 0,//限购直通车产品字段
				limitVIP: 0,//限购VIP产品字段
				limitFuou: 0,//限购复购产品字段
				limitPower: 0,//限购算力产品字段
				limitCount: 1,//限购次数
				replyChance: "",
				reply: [],
				priceName: 0,
				commissionSum: 0,
				nextLevelName: '',
				CartCount: 0,
				posters: false,
				banner: [{}, {}],
				swiperRecommend: {
					pagination: {
						el: ".swiper-pagination",
						clickable: true,
					},
					autoplay: false,
					loop: false,
					speed: 1000,
					observer: true,
					observeParents: true,
				},
				goodList: [],
				systemStore: {},
				qqmapsdk: null,
				productConClass: "product-con",
				tempName: "全国包邮",
				agreementArr: [],
				isPlaceOrder: ''
			};
		},
		computed: mapGetters(["isLogin", "location", "userInfo"]),
		onShow() {
			this.$store.dispatch('getUser', true)
		},
		mounted() {
			this.$store.commit("get_to", "goodcon");
			if (this._route.query.id) {
				this.id = this._route.query.id;
			} else {
				let url = parseQueryItem();
				if (!url) {
					url = handleUrlParam(getCurrentPageUrlWithArgs())

				}
				if (url) {
					var scene = decodeURIComponent(url.scene)
					const part = scene.split('-');
					const parts = part[0].split('=');
					const id = parts[1];
					this.id = id;
				} else {
					this.id = this._route.query.id;
				}
			}

			if (this._route.query.spread) {
				let urlSpread = this._route.query.spread
				cookie.set("spread", urlSpread)
			}

			if (!this.$store.getters.token) {
				this.$yrouter.reLaunch({
					path: "/pages/authorization/index"
				});
			}
			this.coupons();
			this.productCon();
			this.getDealPic()
			this.isPlaceOrder = this.$store.getters.isPlaceOrder
		},
		watch: {
			posterImageStatus(status) {
				console.log(status);
				if (status) {
					this.productConClass = "noscroll product-con";
				} else {
					this.productConClass = "product-con";
				}
			},
		},
		methods: {
			getDealPic(){
				getDealPic().then(res =>{
					console.log(res)
					this.agreementArr = res.data.dealImage.split(',')
				}).catch(err =>{})
			},
			agreeAndContinue(){
				this.agreement = true
			},
			onShareAppMessage: function() {
				return {
					title: this.storeInfo.storeName,
					imageUrl: this.storeInfo.image,
					path: "pages/shop/GoodsCon/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync(
							"uid") +
						"&pageType=good&codeType=routine",
					success(res) {
						uni.showToast({
							title: '分享成功'
						})
					},
					fail(res) {
						uni.showToast({
							title: '分享失败',
							icon: 'none'
						})
					}
				}
			},
			goHome() {
				this.$yrouter.switchTab("/pages/home/index");
			},
			goShoppingCart() {
				this.$yrouter.switchTab("/pages/shop/ShoppingCart/index");
			},
			goCustomerList() {
				this.$yrouter.push({
					path: "/pages/user/CustomerList/index",
				});
			},
			goStoreList() {
				this.$yrouter.push({
					path: "/pages/shop/StoreList/index",
				});
			},
			goEvaluateList(id) {
				this.$yrouter.push({
					path: "/pages/shop/EvaluateList/index",
					query: {
						id,
					},
				});
			},
			telPhone(phoneNumber) {
				uni.makePhoneCall({
					phoneNumber: phoneNumber,
					fail() {
					}
				});
			},
			showChang: function(data) {
				this.$yrouter.push({
					path: "/pages/map/index",
					query: data,
				});
			},
			previewImage(current) {
				uni.previewImage({
					current,
					urls: this.agreementArr,
					success: function(data) {
					},
					fail: function(err) {
					}
				});
			},
			updateTitle() {

			},
			setShareInfoStatus: function() {
				this.shareInfoStatus = !this.shareInfoStatus;
				this.posters = false;
			},
			shareCode: function() {
				var that = this;
				getProductCode(that.id).then((res) => {
					that.posterData.code = res.data.code;
					that.listenerActionSheet();
				});
			},
			setPosterImageStatus: function() {
				this.posterImageStatus = !this.posterImageStatus;
				this.posters = false;
			},
			productCon: function() {
				let that = this;
				let from = this.location;
				if (this.$deviceType == "app") {
					from.from = "app";
				}
				uni.showLoading({
					title: "加载中",
					mask: true
				});
				getProductDetail(that.id, from)
					.then((res) => {
						console.log(res.data)
						uni.hideLoading();
						if(res.data.productDTO.storeInfo.isVirtual == 0){
							that.agreement = true
						}else that.agreement = false
						res.data.productDTO.storeInfo.description = res.data.productDTO.storeInfo.description
							.replace(
								/\<img/gi,
								'<img style="max-width:100%;height:auto;"'
							);
						that.$set(that, "storeInfo", res.data.productDTO.storeInfo);
						that.$set(that.attr, "productAttr", res.data.productDTO.productAttr);
						that.$set(that, "productValue", res.data.productDTO.productValue);
						that.$set(that, "replyCount", res.data.productDTO.replyCount);
						that.$set(that, "replyChance", res.data.productDTO.replyChance);
						that.reply = res.data.reply ? [res.data.productDTO.reply] : [];
						that.$set(that, "reply", that.reply);
						that.isFree = res.data.productDTO.storeInfo.isFree;
						that.frequency = res.data.productDTO.storeInfo.frequency;
						that.cateId = res.data.productDTO.storeInfo.cateId;
						that.is_buy = res.data.is_buy;
						that.derivableCount = res.data.derivableCount;
						that.commissionSum = res.data.commissionSum;
						that.nextLevelName = res.data.nextLevelName;
						that.limitThrough = res.data.limitThrough;
						that.limitVIP = res.data.limitVIP;
						that.limitFuou = res.data.limitFuou;
						that.limitPower = res.data.limitPower;
						that.$set(that, "priceName", res.data.productDTO.priceName);
						that.$set(that, "tempName", res.data.productDTO.tempName);
						that.posterData.image = that.storeInfo.image;
						if (that.storeInfo.storeName.length > 30) {
							that.posterData.title =
								that.storeInfo.storeName.substring(0, 30) + "...";
						} else {
							that.posterData.title = that.storeInfo.storeName;
						}
						that.posterData.price = that.storeInfo.price;
						that.posterData.code = that.storeInfo.codeBase;
						that.systemStore = res.data.productDTO.systemStore;
						let good_list = res.data.goodList || [];
						let goodArray = [];
						let count = Math.ceil(good_list.length / 6);
						for (let i = 0; i < count; i++) {
							var list = good_list.slice(i * 6, 6);
							if (list.length)
								goodArray.push({
									list: list,
								});
						}
						that.mapKay = res.data.productDTO.mapKay;
						that.$set(that, "goodList", goodArray);
						that.updateTitle();
						that.DefaultSelect();
						that.getCartCount();

					})
					.catch((err) => {
						uni.hideLoading();
						uni.showToast({
							title: err.msg || err.response.data.msg || err.response.data.message,
							icon: "none",
							duration: 2000,
						});
						if (err.msg == "商品不存在或已下架") {
							setTimeout(function() {
								that.BackPage()
							}, 2000);
						}

					});
			},
			DefaultSelect: function() {
				let productAttr = this.attr.productAttr;
				let value = [];
				for (let i = 0; i < productAttr.length; i++) {
					this.$set(productAttr[i], "index", 0);
					value.push(productAttr[i].attrValueArr[0]);
				}
				let productSelect = this.productValue[value.sort().join(",")];
				if (productSelect && productAttr.length) {
					this.$set(
						this.attr.productSelect,
						"store_name",
						this.storeInfo.storeName
					);
					this.$set(this.attr.productSelect, "image", productSelect.image);
					this.$set(this.attr.productSelect, "price", productSelect.price);
					this.$set(this.attr.productSelect, "stock", productSelect.stock);
					this.$set(this.attr.productSelect, "unique", productSelect.unique);
					this.$set(this.attr.productSelect, "cart_num", 1);
					this.$set(this, "attrValue", value.sort().join(","));
					this.$set(this, "attrTxt", "已选数量");
				} else if (!productSelect && productAttr.length) {
					this.$set(
						this.attr.productSelect,
						"store_name",
						this.storeInfo.storeName
					);
					this.$set(this.attr.productSelect, "image", this.storeInfo.image);
					this.$set(this.attr.productSelect, "price", this.storeInfo.price);
					this.$set(this.attr.productSelect, "stock", 0);
					this.$set(this.attr.productSelect, "unique", "");
					this.$set(this.attr.productSelect, "cart_num", 0);
					this.$set(this, "attrValue", "");
					this.$set(this, "attrTxt", "已选数量");
				} else if (!productSelect && !productAttr.length) {
					this.$set(
						this.attr.productSelect,
						"store_name",
						this.storeInfo.storeName
					);
					this.$set(this.attr.productSelect, "image", this.storeInfo.image);
					this.$set(this.attr.productSelect, "price", this.storeInfo.price);
					this.$set(this.attr.productSelect, "stock", this.storeInfo.stock);
					this.$set(
						this.attr.productSelect,
						"unique",
						this.storeInfo.unique || ""
					);
					this.$set(this.attr.productSelect, "cart_num", 1);
					this.$set(this, "attrValue", "");
					this.$set(this, "attrTxt", "已选数量");
				}
			},
			BackPage() {
				// #ifdef H5
				const pages = getCurrentPages()
				if (pages.length > 1) {
					uni.navigateBack(1)
					return;
				}
				let a = this.$router.go(-1)
				if (a == undefined) {
					uni.reLaunch({
						url: '/pages/home/index'
					})
				}
				return;
				// #endif
				uni.navigateBack(1)
			},
			//购物车；
			ChangeCartNum: function(changeValue) {
				let productSelect = this.productValue[this.attrValue];
				if (productSelect === undefined && !this.attr.productAttr.length) {
					productSelect = this.attr.productSelect;
				}
				if (productSelect === undefined) return;
				let stock = productSelect.stock || 0;
				let num = this.attr.productSelect;
				if (changeValue) {
					num.cart_num++;
					if (this.isFree == 1) {

						if (num.cart_num > this.derivableCount) {
							this.attr.productSelect.cart_num = this.derivableCount;
							this.cartNum = 1;
							uni.showModal({
								title: '温馨提示',
								content: "本月可免费领取面膜剩余" + this.derivableCount + '次',
								success: function(res) {
									if (res.confirm) {
									} else if (res.cancel) {
									}
								}
							});
						} else {
							this.$set(this.attr.productSelect, "cart_num", num.cart_num);
							this.$set(this, "cart_num", num.cart_num);
						}


					}
					if (this.cateId == 30) {
						if (this.limitThrough == 0) {
						
							if (num.cart_num > this.limitCount) {
								this.attr.productSelect.cart_num = this.limitCount;
								this.cartNum = 1;
								uni.showModal({
									title: '温馨提示',
									content: "此产品限购" + this.limitCount + '次',
									success: function(res) {
										if (res.confirm) {
										} else if (res.cancel) {
										}
									}
								});
							} else {
								this.$set(this.attr.productSelect, "cart_num", num.cart_num);
								this.$set(this, "cart_num", num.cart_num);
							}
						
						
						}
					}
					if (this.cateId == 29) {
						if (this.limitVIP == 0) {
						
							if (num.cart_num > this.limitCount) {
								this.attr.productSelect.cart_num = this.limitCount;
								this.cartNum = 1;
								uni.showModal({
									title: '温馨提示',
									content: "此产品限购" + this.limitCount + '次',
									success: function(res) {
										if (res.confirm) {
										} else if (res.cancel) {
										}
									}
								});
							} else {
								this.$set(this.attr.productSelect, "cart_num", num.cart_num);
								this.$set(this, "cart_num", num.cart_num);
							}
						
						
						}
					}
					if (num.cart_num > stock) {
						this.$set(this.attr.productSelect, "cart_num", stock);
						this.$set(this, "cart_num", stock);
					} else {
						this.$set(this.attr.productSelect, "cart_num", num.cart_num);
						this.$set(this, "cart_num", num.cart_num);
					}
				} else {
					num.cart_num--;
					if (num.cart_num < 1) {
						this.$set(this.attr.productSelect, "cart_num", 1);
						this.$set(this, "cart_num", 1);
					} else {
						this.$set(this.attr.productSelect, "cart_num", num.cart_num);
						this.$set(this, "cart_num", num.cart_num);
					}
				}
			},
			changeFun: function(opt) {
				if (typeof opt !== "object") opt = {};
				let action = opt.action || "";
				let value = opt.value === undefined ? "" : opt.value;
				this[action] && this[action](value);
			},
			couponTap: function() {
				let that = this;
				that.coupons();
				that.coupon.coupon = true;
			},
			changecoupon: function(msg) {
				this.coupon.coupon = msg;
				this.coupons();
			},
			currentcoupon: function(res) {
				let that = this;
				that.coupon.coupon = false;
				that.$set(that.coupon.list[res], "is_use", true);
			},
			coupons: function() {
				let that = this,
					q = {
						page: 1,
						limit: 20,
					};
				getCoupon(q).then((res) => {

					that.$set(that, "couponList", res.data || []);
					that.$set(that.coupon, "list", res.data);
				});
			},
			selecAttrTap: function() {
				this.attr.cartAttr = true;
				this.isOpen = true;
			},
			changeattr: function(msg) {
				this.attr.cartAttr = msg;
				this.isOpen = false;
			},
			ChangeAttr: function(res) {

				let productSelect = this.productValue[res.value];
				if (productSelect) {
					this.attr.productAttr[res.indexw].index = res.indexn;
					this.$set(this.attr.productSelect, "image", productSelect.image);
					this.$set(this.attr.productSelect, "price", productSelect.price);
					this.$set(this.attr.productSelect, "stock", productSelect.stock);
					this.$set(this.attr.productSelect, "unique", productSelect.unique);
					this.$set(this.attr.productSelect, "cart_num", 1);
					this.$set(this, "attrValue", res.value);
					this.$set(this, "attrTxt", "已选数量");
				} else {
					this.$set(this.attr.productSelect, "image", this.storeInfo.image);
					this.$set(this.attr.productSelect, "price", this.storeInfo.price);
					this.$set(this.attr.productSelect, "stock", 0);
					this.$set(this.attr.productSelect, "unique", "");
					this.$set(this.attr.productSelect, "cart_num", 0);
					this.$set(this, "attrValue", "");
					this.$set(this, "attrTxt", "已选数量");
				}
			},
			//收藏商品
			setCollect: function() {
				let that = this,
					id = that.storeInfo.id,
					category = "collect";
				if (that.storeInfo.userCollect) {
					getCollectDel(id, category).then(function() {
						that.storeInfo.userCollect = !that.storeInfo.userCollect;
						uni.showToast({
							title: "已经取消收藏",
							icon: "success",
							duration: 2000,
						});
					});
				} else {
					getCollectAdd(id, category).then(function() {
						that.storeInfo.userCollect = !that.storeInfo.userCollect;
						uni.showToast({
							title: "收藏成功",
							icon: "success",
							duration: 2000,
						});
					});
				}
			},
			joinCart: function() {
				this.goCat(0);
			},
			goCat: function(news) {
				if (!this.userInfo.status) {
					systemPrompt()
					return
				}
				if (this.cateId == 20) {
					uni.showModal({
						title: '温馨提示',
						content: '此产品不能添加到购物车',
						success: function(res) {
							if (res.confirm) {
							} else if (res.cancel) {
							}
						}
					});
					return
				}
				//console.log(this.limitThrough);
				//console.log(this.limitVIP);
				if (this.limitThrough == 1) {
					uni.showModal({
						title: '温馨提示',
						content: '只有游客或VIP才可购买此产品',
						success: function(res) {
							if (res.confirm) {
							} else if (res.cancel) {
							}
						}
					});
					return
				}
				
				if (this.limitVIP == 1) {
					uni.showModal({
						title: '温馨提示',
						content: '只有游客才可购买此产品',
						success: function(res) {
							if (res.confirm) {
							} else if (res.cancel) {
							}
						}
					});
					return
				}
				
				if (this.limitFuou == 1) {
					uni.showModal({
						title: '温馨提示',
						content: '只有联创以上才可购买此产品',
						success: function(res) {
							if (res.confirm) {
							} else if (res.cancel) {
							}
						}
					});
					return
				}
				
				if (this.limitPower == 1) {
					uni.showModal({
						title: '温馨提示',
						content: '只有VIP以上才可购买此产品',
						success: function(res) {
							if (res.confirm) {
							} else if (res.cancel) {
							}
						}
					});
					return
				}

				if (news == 0) {
					if (this.isFree == 1) {
						uni.showModal({
							title: '温馨提示',
							content: '此产品不能添加到购物车',
							success: function(res) {
								if (res.confirm) {
								} else if (res.cancel) {
								}
							}
						});
						return
					}
				}


				let that = this,
					productSelect = that.productValue[this.attrValue]
				//打开属性
				if (that.attrValue) {
					that.attr.cartAttr = !that.isOpen ? true : false
				} else {
					if (that.isOpen) that.attr.cartAttr = true
					else that.attr.cartAttr = !that.attr.cartAttr
				}
				if (that.attr.cartAttr === true && that.isOpen === false)
					return (that.isOpen = true);
				if (
					that.attr.productAttr.length &&
					productSelect === undefined &&
					that.isOpen === true
				) {
					uni.showToast({
						title: "产品库存不足，请选择其它",
						icon: "none",
						duration: 2000,
					});
					return;
				}
				let q = {
					productId: that.id,
					cartNum: that.attr.productSelect.cart_num,
					new: news,
					uniqueId: that.attr.productSelect !== undefined ?
						that.attr.productSelect.unique : "",
				};
				uni.showLoading({
					title: "加载中"
				});
				postCartAdd(q)
					.then(function(res) {
						uni.hideLoading();
						that.isOpen = false;
						that.attr.cartAttr = false;
						
						
						if (news) {
							that.$yrouter.push({
								path: "/pages/order/OrderSubmission/index",
								query: {
									id: res.data.cartId,
								},
							});
						} else {
							uni.showToast({
								title: "添加购物车成功",
								icon: "success",
								duration: 2000,
								complete: () => {
									that.getCartCount(true);
								},
							});
						}
					})
					.catch((error) => {
						uni.hideLoading();
						that.isOpen = false;
						uni.showToast({
							title: error.response.data.msg,
							icon: "none",
							duration: 2000,
						});
					});
			},
			getCartCount: function(isAnima) {
				let that = this;
				const isLogin = that.isLogin;
				if (isLogin) {
					getCartCount({
						numType: 0,
					}).then((res) => {
						that.CartCount = res.data.count;
						if (isAnima) {
							that.animated = true;
							setTimeout(function() {
								that.animated = false;
							}, 500);
						}
					});
				}
			},
			tapBuy: function() {
				if (!this.userInfo.status) {
					systemPrompt()
					return
				}
				if (this.cateId == 20) {
					uni.showModal({
						title: '温馨提示',
						content: '此产品为秒杀活动产品，不能在此下单',
						success: function(res) {
							if (res.confirm) {
							} else if (res.cancel) {
							}
						}
					});
					return
				}
				if(this.userInfo.nickname == '' || this.userInfo.nickname == '微信用户' || this.userInfo.nickname == null){
					uni.showModal({
						title: '温馨提示',
						content: '请完善用户昵称和头像',
						success: function(res) {
							if (res.confirm) {
								this.$yrouter.push({
									path: '/pages/user/PersonalData/index'
								})
							} else if (res.cancel) {}
						}.bind(this)
					});
					return
				}
				if (this.isFree == 1) {
					if (this.userInfo.vipId > 0 && this.userInfo.vipId <= 5) {
						if (this.is_buy == 'N') {
							uni.showModal({
								title: '温馨提示',
								content: '您本月已领取4次，已达当月上限，无法再领取此产品',
								success: function(res) {
									if (res.confirm) {
									} else if (res.cancel) {
									}
								}
							});
							return
						}
					} else {
						uni.showModal({
							title: '温馨提示',
							content: '您的账户为普通会员，无法领取此产品！',
							success: function(res) {
								if (res.confirm) {
								} else if (res.cancel) {
								}
							}
						});
						return
					}

				}
				
				if(this.isPlaceOrder == 0){
					if (this.userInfo.uid != 666) {
						if (this.userInfo.spreadUid == 0) {
							uni.showToast({
								title: "该用户没有上级无法购买商品，请扫描推广二维码注册用户再购买",
								icon: "none",
								duration: 3000,
							});
							return;
						}
					}
				}
				
				if (this.userInfo.phone == '' || this.userInfo.phone == null) {
					uni.showToast({
						title: "您还未绑定手机，请前往个人中心绑定手机再购买",
						icon: "none",
						duration: 3000,
					});
					return;
				}
				//  1=直接购买
				this.goCat(1);
			},
			listenerActionSheet: function() {
				if (!this.userInfo.status) {
					systemPrompt()
					return
				}
				if(this.userInfo.uid != 666 && this.userInfo.uid != 777 && this.userInfo.uid != 888 && this.userInfo.uid != 999){
					if(this.userInfo.spreadUid == 0 || this.userInfo.level == 1){
						uni.showModal({
							title: '提示',
							content: '您还没有绑定上级或者未成为会员，暂不能使用分享海报！',
							success: function(res) {
								if (res.confirm) {} else if (res.cancel) {}
							}
						});
						return
					}
					/* else{
						if(this.userInfo.isOpenLian !='Y'){
							uni.showModal({
								title: '提示',
								content: '推广二维码需要新媒体讲师权限，是否完成问卷考核成为讲师？',
								success: function(res) {
									if (res.confirm) {
										this.$yrouter.push({
											path: '/pagesB/view/questionnaire/index',
											query: {
												type: 3,
											},
										});
									} else if (res.cancel) {}
								}.bind(this)
							});
							return
						}
					} */
				}
				if(this.userInfo.nickname == '' || this.userInfo.nickname == '微信用户' || this.userInfo.nickname == null){
					uni.showModal({
						title: '温馨提示',
						content: '请完善用户昵称和头像',
						success: function(res) {
							if (res.confirm) {
								this.$yrouter.push({
									path: '/pages/user/PersonalData/index'
								})
							} else if (res.cancel) {}
						}.bind(this)
					});
					return
				}
				if (isWeixin() === true) {
					this.weixinStatus = true;
				}
				this.posters = true;

				this.setPosterImageStatus()
			},
			listenerActionClose: function() {
				this.posters = false;
			},
			setOpenShare: function() {
				var data = this.storeInfo;
				var href = this.location.href;
				if (this.$deviceType == "weixin") {
					if (this.isLogin) {
						getUserInfo().then((res) => {
							href =
								href.indexOf("?") === -1 ?
								href + "?spread=" + res.data.uid :
								href + "&spread=" + res.data.uid;
							var configAppMessage = {
								desc: data.storeInfo,
								title: data.storeName,
								link: href,
								imgUrl: data.image,
							};
							wechatEvevt(
									["updateAppMessageShareData", "updateTimelineShareData"],
									configAppMessage
								)
								.then((res) => {

								})
								.catch((res) => {

									if (res.is_ready) {
										res.wx.updateAppMessageShareData(configAppMessage);
										res.wx.updateTimelineShareData(configAppMessage);
									}
								});
						});
					} else {
						var configAppMessage = {
							desc: data.storeInfo,
							title: data.storeName,
							link: href,
							imgUrl: data.image,
						};
						wechatEvevt(
								["updateAppMessageShareData", "updateTimelineShareData"],
								configAppMessage
							)
							.then((res) => {

							})
							.catch((res) => {

								if (res.is_ready) {
									res.wx.updateAppMessageShareData(configAppMessage);
									res.wx.updateTimelineShareData(configAppMessage);
								}
							});
					}
				}
			},
		},
	};
</script>
<style lang="less">
	
	.post-about {
		height: 100%;
		width: 100%;
		overflow-y: hidden;
	
		.content {
			
			height: 100%;
			width: 100%;
			overflow-y: auto;
			padding-top: 0rpx;
			
			image {
				width: 100%;
			}
			
		}
		
		.btn{
			height: 80rpx;
			line-height: 80rpx;
			color: #FFFFFF;
			background-color: #FF2358;
			border-radius: 80rpx;
			width: calc(100% - 120rpx);
			text-align: center;
			position: fixed;
			bottom: 30rpx;
			left: 60rpx;
		}
	}
	
	.geoPage {
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		z-index: 10000;
	}

	.labelNav {
		width: 100%;
		height: 76rpx;
		background-color: #f5f5f5;
		display: table;

		.item {
			display: table-cell;
			vertical-align: middle;
			height: 76rpx;
			text-align: center;
			font-size: 28rpx;
			color: #8c8c8c;

			text {
				font-size: 28rpx;
			}
		}
	}

	.wrapper {
		.share {
			.iconfont {
				text-align: center;
				position: relative;
				.shareButton {
					font-size: 28rpx;
					display: block;
					position: absolute;
					right: -10rpx;
					top: 45rpx;
					width: 60rpx;
				}
			}
		}
		
		
		
		.discount_view{
			height: auto;
			overflow: hidden;
			padding: 0 30rpx;
			margin-top: 20rpx;
			
			.icon{
				height: 45rpx;
				width: 45rpx;
				float: left;
				overflow: hidden;
				border-radius: 45rpx;
				
				image{
					height: 100%;
					width: 100%;
				}
			}
			
			.content_box{
				height: 50rpx;
				line-height: 43rpx;
				font-size: 30rpx;
				color: #222222;
				float: left;
				margin-left: 15rpx;
			}
		}
	}
	
	.product-con{
		.store-info {
			margin-top: 0.2 * 100rpx;
			background-color: #fff;
			
			.title {
				padding: 0 0.3 * 100rpx;
				font-size: 0.28 * 100rpx;
				color: #282828;
				height: 0.8 * 100rpx;
				line-height: 0.8 * 100rpx;
				border-bottom: 0.01 * 100rpx solid #f5f5f5;
			}
			
			.info {
				padding: 0 0.3 * 100rpx;
				height: 1.26 * 100rpx;
				
				.picTxt {
					width: 100%;
					display: flex;
					align-items: center;

					.pictrue {
						width: 0.76 * 100rpx;
						height: 0.76 * 100rpx;
						margin-right: 0.2 * 100rpx;
						
						image {
							width: 100%;
							height: 100%;
							border-radius: 0.06 * 100rpx;
						}
					}
					
					.text {
						flex: 1;
						
						.name {
							font-size: 0.3 * 100rpx;
							color: #282828;
						}
						
						.address {
							font-size: 0.24 * 100rpx;
							color: #666;
							margin-top: 0.03 * 100rpx;
							
							.iconfont {
								color: #707070;
								font-size: 0.18 * 100rpx;
								margin-left: 0.1 * 100rpx;
							}
						}
					}
					
					
					.addressBox {
						display: flex;
						flex-direction: column;
						align-items: flex-end;
						
						.iconfont {
							font-size: 0.4 * 100rpx;
						}
						
						.addressTxt {
							font-size: 0.24 * 100rpx;
							color: #eb3729;
						}
					}
				}
			}
			
			
			.praise {
				font-size: 0.28 * 100rpx;
				color: #808080;
				
				.iconfont {
					font-size: 0.28 * 100rpx;
				}
			}
		}
		
		
		.superior {
			background-color: #fff;
			margin-top: 0.2 * 100rpx;
			
			.title {
				height: 0.98 * 100rpx;
				
				image {
					width: 0.3 * 100rpx;
					height: 0.3 * 100rpx;
				}
				
				.titleTxt {
					margin: 0 0.2 * 100rpx;
					font-size: 0.3 * 100rpx;
					background-image: linear-gradient(to right, #f57a37 0%, #f21b07 100%);
					background-image: -webkit-linear-gradient(to right, #f57a37 0%, #f21b07 100%);
					background-image: -moz-linear-gradient(to right, #f57a37 0%, #f21b07 100%);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
				}
			}
			
			.slider-banner {
				width: 6.9 * 100rpx;
				margin: 0 auto;
				padding-bottom: 0.2 * 100rpx;
				
				.list {
					width: 100%;
					padding-bottom: 0.2 * 100rpx;
					
					.item {
						width: 2.15 * 100rpx;
						margin: 0 0.22 * 100rpx 0.3 * 100rpx 0;
						font-size: 0.26 * 100rpx;
						
						.pictrue {
							width: 100%;
							height: 2.15 * 100rpx;
							
							image {
								width: 100%;
								height: 100%;
								border-radius: 0.06 * 100rpx;
							}
						}
						
						.name {
							color: #282828;
							margin-top: 0.12 * 100rpx;
						}
					}
					
					.item:nth-of-type(3n) {
						margin-right: 0;
					}
				}
				
				
				.swiper-pagination-bullet {
					background-color: #999;
				}
				
				.swiper-pagination-bullet-active {
					background-color: #e93323;
				}
			}
		}
	}
	.mask {
		-webkit-filter: blur(2px);
		-moz-filter: blur(2px);
		-ms-filter: blur(2px);
		filter: blur(2px);
	}
	.product-con .product-intro .conter view {
		width: 100% !important;
	}
	.generate-posters {
		width: 100%;
		height: 1.7 * 100rpx;
		background-color: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 99;
		transform: translate3d(0, 100%, 0);
		-webkit-transform: translate3d(0, 100%, 0);
		-ms-transform: translate3d(0, 100%, 0);
		-moz-transform: translate3d(0, 100%, 0);
		-o-transform: translate3d(0, 100%, 0);
		transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
		-webkit-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
		-moz-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
		-o-transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
		
		.item {
			flex: 50%;
			-webkit-flex: 50%;
			-ms-flex: 50%;
			text-align: center;
			
			.iconfont {
				font-size: 0.8 * 100rpx;
				color: #5eae72;
			}
		}
	}
	.generate-posters.on {
		transform: translate3d(0, 0, 0);
		-webkit-transform: translate3d(0, 0, 0);
		-ms-transform: translate3d(0, 0, 0);
		-moz-transform: translate3d(0, 0, 0);
		-o-transform: translate3d(0, 0, 0);
	}
	.generate-posters .item .iconfont.icon-haibao {
		color: #5391f1;
	}
	.noscroll {
		height: 100%;
		overflow: hidden;
	}
	
	.footer {
		box-sizing: border-box;
		padding: 0 0 0 0;
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 100rpx;
		background-color: #fff;
		z-index: 99 !important;
		display: table;
		table-layout: fixed;
	
		.item {
			display: table-cell;
			vertical-align: middle;
			height: 100%;
			text-align: center;
			position: relative;
	
			.iconfont {
				text-align: center;
	
				image {
					height: 50rpx;
					width: 50rpx;
				}
	
				text {
					position: absolute;
					top: 0rpx;
					right: 19rpx;
					height: 35rpx;
					width: 35rpx;
					text-align: center;
					line-height: 35rpx;
					border-radius: 100rpx;
					background-color: #FF3334;
					color: #FFFFFF;
					font-size: 16rpx !important;
				}
			}
	
			text {
				display: block;
				text-align: center;
				font-size: 28rpx;
				margin-top: 12rpx;
			}
		}
	
		.joinCart {
			width: 30%;
			padding-left: 20rpx;
			
			text {
				font-size: 32rpx;
				padding: 18rpx 0;
				border-top-left-radius: 100rpx;
				border-bottom-left-radius: 100rpx;
				background-color: #ea885b;
				color: rgba(255, 255, 255, 0.8) !important;
			}
		}
	
		.buy {
			/*  #ifdef MP-WEIXIN */
			width: 70%;
			/*  #endif  */
			/*  #ifdef H5  */
			width: 65%;
			/*  #endif  */
			padding-right: 20rpx;
			
	
			text {
				font-size: 32rpx;
				background-color: #e45050;
				padding: 18rpx 0;
				color: rgba(255, 255, 255, 0.8) !important;
				border-bottom-right-radius: 100rpx;
				border-top-right-radius: 100rpx;
				border-top-left-radius: 100rpx;
				border-bottom-left-radius: 100rpx;
			}
			
			button{
				background-color: #e45050;
				color: #ffffff;
				border-radius: 60rpx;
				height: 80rpx;
				line-height: 80rpx;
			}
		}
		
		.buy-border{
			text{
				border-top-left-radius: 100rpx!important;
				border-bottom-left-radius: 100rpx!important;
			}
		}
		
		.customer-service{
			width: 60%;
		}
	}
</style>
